#include <cnix/types.h>
#include <cnix/fs.h>
#include <cnix/kernel.h>

static void dummy_inode_free(struct inode * inoptr);
static BOOLEAN dummy_can_delete(struct inode * inoptr);
static int dummy_truncate(struct inode * inoptr, off_t length);
static off_t dummy_size(struct inode * inoptr);
static void dummy_setsize(struct inode * inoptr, off_t size);
static mode_t dummy_mode(struct inode * inoptr);
static void dummy_setmode(struct inode * inoptr, mode_t mode);
static dev_t dummy_realdev(struct inode * inoptr);
static BOOLEAN dummy_minode(
	struct inode * inoptr, off_t pos, unsigned long block
	);
static unsigned long dummy_bmap(struct inode * inoptr, off_t pos);
static BOOLEAN dummy_noitem(struct inode * inoptr);
static BOOLEAN dummy_additem(
	struct inode * inoptr, const char * name, int * error, ino_t ino
	);
static BOOLEAN dummy_delitem(
	struct inode * inoptr, const char * name, int * error
	);
static ino_t dummy_findson(struct inode * inoptr, const char * name);
static BOOLEAN dummy_real_filename(
	char * page, struct inode * inoptr, int * error
	);
static uid_t dummy_getuid(struct inode * inoptr);
static void dummy_setuid(struct inode * inoptr, uid_t uid);
static gid_t dummy_getgid(struct inode * inoptr);
static void dummy_setgid(struct inode * inoptr, gid_t gid);
static void dummy_mknod(struct inode * inoptr, dev_t dev);
static int dummy_blocksize(struct inode * inoptr);
static off_t dummy_max_filesize(struct inode * inoptr);
static void dummy_update(
	struct inode * inoptr, time_t atime, time_t mtime, time_t ctime
	);
static nlink_t dummy_change_nlinks(struct inode * inoptr, int change);
static int dummy_get_name_of_son(
	struct inode * fino, ino_t inum, char * name, int size
	);
static int dummy_stat(struct inode * inoptr, struct stat * statbuf);
static int dummy_readdir(int fd, struct dirent * dirp);

struct inode_operation dummy_inode_operation = {
	&dummy_inode_free,
	&dummy_can_delete,
	&dummy_truncate,
	&dummy_size,
	&dummy_setsize,
	&dummy_mode,
	&dummy_setmode,
	&dummy_realdev,
	&dummy_real_filename,
	&dummy_minode,
	&dummy_noitem,
	&dummy_additem,
	&dummy_delitem,
	&dummy_findson,
	&dummy_getuid,
	&dummy_setuid,
	&dummy_getgid,
	&dummy_setgid,
	&dummy_mknod,
	&dummy_bmap,
	&dummy_blocksize,
	&dummy_max_filesize,
	&dummy_update,
	&dummy_change_nlinks,
	&dummy_get_name_of_son,
	&dummy_stat,
	&dummy_readdir,
};

static char * inode_type_names[] = { "", "socket", "pipe", "onhd" };

#define DECLARATION(type) \
	PRINTK("i'm a %s.\n", inode_type_names[(int)type])

static void dummy_inode_free(struct inode * inoptr)
{
	DECLARATION(inoptr->i_type);
}

static BOOLEAN dummy_can_delete(struct inode * inoptr)
{
	DECLARATION(inoptr->i_type);
	return FALSE;
}

static int dummy_truncate(struct inode *inoptr, off_t length)
{
	DECLARATION(inoptr->i_type);
	return 0;
}

static off_t dummy_size(struct inode * inoptr)
{
	DECLARATION(inoptr->i_type);
	return 0;
}

static void dummy_setsize(struct inode * inoptr, off_t size)
{
	DECLARATION(inoptr->i_type);
}

static mode_t dummy_mode(struct inode * inoptr)
{
	DECLARATION(inoptr->i_type);
	return 0;
}

static void dummy_setmode(struct inode * inoptr, mode_t mode)
{
	DECLARATION(inoptr->i_type);
}

static dev_t dummy_realdev(struct inode * inoptr)
{
	DECLARATION(inoptr->i_type);
	return NODEV;
}

static unsigned long dummy_bmap(struct inode * inoptr, off_t pos)
{
	DECLARATION(inoptr->i_type);
	return NOBLK;
}

static BOOLEAN dummy_minode(struct inode * inoptr, off_t pos, unsigned long blk)
{
	DECLARATION(inoptr->i_type);
	return FALSE;
}

static BOOLEAN dummy_noitem(struct inode * inoptr)
{
	DECLARATION(inoptr->i_type);
	return TRUE;
}

static BOOLEAN dummy_additem(
	struct inode * inoptr, const char * name, int * error, ino_t ino
	)
{
	DECLARATION(inoptr->i_type);
	return FALSE;
}

static BOOLEAN dummy_delitem(
	struct inode * inoptr, const char * name, int * error
	)
{
	DECLARATION(inoptr->i_type);
	return FALSE;
}

static ino_t dummy_findson(struct inode * inoptr, const char * name)
{
	DECLARATION(inoptr->i_type);
	return NOINO;
}

static BOOLEAN dummy_real_filename(
	char * page, struct inode * inoptr, int * error
	)
{
	DECLARATION(inoptr->i_type);
	return FALSE;
}

static uid_t dummy_getuid(struct inode * inoptr)
{
	DECLARATION(inoptr->i_type);
	return 0;
}

static void dummy_setuid(struct inode * inoptr, uid_t uid)
{
	DECLARATION(inoptr->i_type);
}

static gid_t dummy_getgid(struct inode * inoptr)
{
	DECLARATION(inoptr->i_type);
	return 0;
}

static void dummy_setgid(struct inode * inoptr, gid_t gid)
{
	DECLARATION(inoptr->i_type);
}

static void dummy_mknod(struct inode * inoptr, dev_t dev)
{
	DECLARATION(inoptr->i_type);
}

static int dummy_blocksize(struct inode * inoptr)
{
	DECLARATION(inoptr->i_type);
	return 0;
}

static off_t dummy_max_filesize(struct inode * inoptr)
{
	DECLARATION(inoptr->i_type);
	return 0;
}

static void dummy_update(
	struct inode * inoptr, time_t atime, time_t mtime, time_t ctime
	)
{
	DECLARATION(inoptr->i_type);
}

static nlink_t dummy_change_nlinks(struct inode * inoptr, int change)
{
	DECLARATION(inoptr->i_type);
	return 0;
}

static int dummy_get_name_of_son(
	struct inode * fino, ino_t inum, char * name, int size
	)
{
	DECLARATION(fino->i_type);
	return 0;
} 

static int dummy_stat(struct inode * inoptr, struct stat * statbuf)
{
	DECLARATION(inoptr->i_type);
	return 0;
}

static int dummy_readdir(int fd, struct dirent * dirp)
{
	DECLARATION(fget(fd)->f_ino->i_type);
	return 0;
}
